package com.briup.Utils;

import com.alibaba.druid.pool.DruidDataSourceFactory;
import com.alibaba.druid.util.JdbcUtils;

import java.io.FileReader;
import java.io.IOException;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Properties;

/**
 * 读取.properties结尾的配置文件
 * 通过get方法，传入参数key，返回String类型value
 */
public class PropertiesUtil {

    private static Properties properties;
    //静态代码块 类加载的时候自动执行
    static {
        properties = new Properties();
        //加载配置文件
        try {
            properties.load(new FileReader("D:\\training2\\idea_code\\Smart\\src\\main\\resources\\druid.properties"));
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
    public static String getValueByKey(String key){
            //返回值
            String value = properties.getProperty(key);
            return value;
    }
    public static java.util.Properties getProperties(){
        return properties;
    }

}
